extends Area2D

@onready var audio_player: AudioStreamPlayer2D = $CoinAudio
@onready var coin_animation: AnimatedSprite2D = $CoinAnimation

func _ready() -> void:
	coin_animation.play("coin")

func _on_body_entered(body:Node2D) -> void:
	if body.is_in_group("player"):
		audio_player.play()
		audio_player.seek(0.3)
		hide()
		EventBus.emit_signal("coin_collected")  # 新增事件触发
		await audio_player.finished
		queue_free()
		
